import { Core } from '../../utils/config.js';
export default function request(url, params, callback) {
  if (!url || !params) return;
  params = { ...params, domain: Core.domain };
  url = `${Core.apiBase}${url}`;
  wx.request({
    url,
    data: JSON.stringify(params),
    method: 'POST',
    success(response = {}) {
      const fetchResult = response.data;
      if (fetchResult && fetchResult.code > 0) {
        callback && callback('SUCCESS', fetchResult);
      } else {
        callback && callback('FAIL', fetchResult);
      }
    },
    fail(response = {}) {
      const fetchResult = response.data;
      callback && callback('FAIL', fetchResult);
    },
  });
}